package com.tw;

import java.util.*;

class Stack<T> {
    private ArrayList<T> dataSet= new ArrayList<T>();
    private int top;

    Stack(){
        this.top = -1;
    }

    void push(T data){
        top++;
        dataSet.add(data);

    }

    T pop(){
        T result = null;

        if(!isEmpty()){
            result = dataSet.get(top);
            dataSet.remove(top);
            top--;
        }

        return result;
    }

    boolean isEmpty(){
        return (top < 0 );
    }


}




